package com.common.utils;

/**
 * @author Tsing
 * 基于ThreadLocal的本地线程类 存储当前线程的用户Id
 */
public class LocalContext {
    private static ThreadLocal<Integer> threadLocal = new ThreadLocal<>();

    public static void remove(){
        threadLocal.remove();
    }

    public static void setCurrentUserId(Integer userId){
        threadLocal.set(userId);
    }

    public static Integer getCurrentUserId(){
        return threadLocal.get();
    }
}
